//
//  BukaDefinition.h
//  BukaLiveUILibrary
//
//  Created by 曹飞 on 2018/3/15.
//  Copyright © 2018年 tv.buka. All rights reserved.
//

#import "UIDevice+BKDevice.h"

#ifndef BukaDefinition_h
#define BukaDefinition_h


#endif /* BukaDefinition_h */

#pragma mark - 缓存字段
#define BKUSER_DEFAULT [NSUserDefaults standardUserDefaults]  //实例化
#define kUserDefaultPhoneNum @"UserDefaultPhoneNum"

#pragma mark - 常用代码
#ifndef __OPTIMIZE__
#define DLog(...) NSLog(__VA_ARGS__)
#else
#define DLog(...) {}
#endif

#define dispatch_main_sync_safe_BK(block)\
if ([NSThread isMainThread]) {\
block();\
} else {\
dispatch_sync(dispatch_get_main_queue(), block);\
}


#define BKPrintFunc DLog(@"MARK: %s, %d", __PRETTY_FUNCTION__, __LINE__);
#define BKWeakSelf __weak typeof(self) weakSelf = self;

#pragma mark - 系统信息
#define currentSystemVersion [[[UIDevice currentDevice] systemVersion] floatValue]
#define BK_IOS7        (currentSystemVersion>=7.0)
#define BK_IOS8        (currentSystemVersion>=8.0)
#define BK_IOS9        (currentSystemVersion>=9.0)
#define BK_IOS10       (currentSystemVersion>=10.0)
#define BK_IOS11       (currentSystemVersion>=11.0)



#pragma mark - 设备视图尺寸
#define BK_VIEW_WIDTH self.view.frame.size.width
#define BK_VIEW_HEIGHT self.view.frame.size.height
#define BK_SCREEN_WIDTH [[UIScreen mainScreen] bounds].size.width
#define BK_SCREEN_HEIGHT [[UIScreen mainScreen] bounds].size.height



#pragma mark - 颜色
#define UIColorFromHex(s,a)  [UIColor colorWithRed:(((s & 0xFF0000) >> 16))/255.0 green:(((s &0xFF00) >>8))/255.0 blue:((s &0xFF))/255.0 alpha:a]
#define COLOR(value)    [UIColor colorWithHexString:(value)]
#define RGBAColor(r,g,b,a)        [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
#define RGBCOLOR(r,g,b) RGBAColor(r,g,b,1)
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#define RGB(r,g,b) RGBA(r,g,b,1.0f)
#define CLEARCOLOR [UIColor clearColor]


#define APP_THEME_COLOR [UIColor colorWithHexString:@"3691e3"]  //整个应用主题颜色，包括按钮主题颜色，导航栏颜色等等...

#define TITLE_BKG_COLOR [UIColor colorWithHexString:@"f7f7f7"]
#define CONTENT_BKG_COLOR [UIColor colorWithHexString:@"eeeeee"]
#define LINE_COLOR [UIColor colorWithHexString:@"d8d8d8"]
#define BUTTON_COLOR [UIColor colorWithHexString:@"cd3131"]
#define TEXT_COLOR_GRAY [UIColor colorWithHexString:@"eeeeee"]
#define TEXT_COLOR_WHITE [UIColor colorWithHexString:@"ffffff"]

#define TEXT_COLOR_BLUE [UIColor colorWithHexString:@"00bcf6"]


#pragma mark - 文字相关

#define BK_BOLD_FONT_SIZE [UIFont boldSystemFontOfSize:16]      //文字大小
#define BK_BOLD_FONT_SIZE_SYS [UIFont systemFontOfSize:16]      //不加粗
#define BK_CELLTITLE_FONT_SIZE [UIFont boldSystemFontOfSize:16]      //cell title文字大小
#define BK_CELLTITLE_FONT_SIZE_SYS [UIFont systemFontOfSize:15]      //不加粗
#define BK_CELLSUBTITLE_FONT_SIZE [UIFont systemFontOfSize:15]      //cell 子标题文字大小
#define BK_CELLTIME_FONT_SIZE [UIFont systemFontOfSize:11]      //cell 时间文字大小
#define BK_STORAGEDOWNLOAD_SIZE [UIFont systemFontOfSize:11]    // 共享盘下载文字大小

#define APP_THEME_COLOR_WORD [UIColor whiteColor]               //文字颜色
#define APP_THEME_COLOR_WORD_REMARK [UIColor whiteColor]        //备注文字颜色
#define APP_THEME_COLOR_WORD_PLACEHOLDER RGBCOLOR( 170,166,164)   //输入框Placeholder 颜色 170 166 164
#define APP_THEME_COLOR_WORD_CELLTITLE [UIColor colorWithHexString:@"202020"] //cell title文字颜色
#define APP_THEME_COLOR_WORD_SUBTITLE  [UIColor colorWithHexString:@"787878"] //cell 子标题文字颜色
#define APP_THEME_COLOR_WORD_LINE [UIColor colorWithHexString:@"dcdcdc"]//线的颜色
#define BK_STORAGE_HEADERVIEW_BACKGROUND_COLOR COLOR(@"effef4")   // 共享盘头部视图背景颜色


#define DEFAULT_BKG_COLOR RGBCOLOR(239, 239, 246) //默认背景灰色



#pragma mark -  设备信息

#define BK_IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define BK_IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)

#define BK_iPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
#define BK_iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
#define BK_iPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)

#define BK_iPhone6p ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)
#define IsiPhone11 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) : NO)
#define IsiPhone11Pro ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
#define IsiPhone11ProMax ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) : NO)


#define BK_iPhoneX [[[UIDevice currentDevice] getDeviceType]isEqualToString:@"iPhone X"]||[[[UIDevice currentDevice] getDeviceType]isEqualToString:@"iPhone XR"]||[[[UIDevice currentDevice] getDeviceType]isEqualToString:@"iPhone XS Max"]||[[[UIDevice currentDevice] getDeviceType]isEqualToString:@"Simulator"]||IsiPhone11||IsiPhone11Pro||IsiPhone11ProMax?YES:NO


#define ASLocalizedStringFromTable(key,tbl)  [NSString stringWithFormat:@"%@", [[NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"appLanguage"]] ofType:@"lproj"]] localizedStringForKey:(key) value:nil table:@"Localizable"]]

